package org.example.ui;

import org.apache.ibatis.session.SqlSession;
import org.example.entity.Grade;
import org.example.entity.Student;
import org.example.mapper.GradeMapper;
import org.example.util.MyBatisUtil;

import java.util.List;

public class GetGradesAndStudents {
    public static void main(String[] args) {
        SqlSession sqlSession= MyBatisUtil.getSession();
        GradeMapper gradeMapper=sqlSession.getMapper(GradeMapper.class);
        List<Grade> grades=gradeMapper.getGradesAndStudents();
        for (Grade grade:grades){
            System.out.println(grade.getGid()+"\t"+grade.getGname());
            List<Student> students=grade.getStudents();
            for (Student student:students){
                System.out.println(student.toString());
            }
        }
    }
}
